package com.java01.apache.commons.collections;

import org.apache.commons.collections.MapIterator;
import org.apache.commons.collections.OrderedMap;
import org.apache.commons.collections.map.LinkedMap;

public class LinkedMapSnippet {

	public static void main(String[] args) {
		OrderedMap map = new LinkedMap();
		map.put("A", "1");
		map.put("B", "2");
		map.put("C", "3");
		
		System.out.println("1. "+map.firstKey());
		System.out.println("2. "+map.nextKey("A"));
		System.out.println("3. "+map.nextKey("B"));
		System.out.println("4. "+map.nextKey("C"));
		System.out.println("5. "+map.lastKey());
		System.out.println("6. "+map.containsKey("A"));
		System.out.println("7. "+map.containsValue("3"));
		System.out.println("8. "+map.containsValue("4"));
		
		map.put("B", "b");
		
		MapIterator it=map.mapIterator();
		while(it.hasNext()){
			Object key=it.next();
			Object value=it.getValue();
			System.out.println(key+"->"+value);
		}
	}
}
